package com.storage.mongo;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.bson.types.ObjectId;

import com.google.code.morphia.annotations.Embedded;
import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;
import com.wink.common.Identity;

@Entity
public class MongoIdentity {

	private String fromCommunity;	
	private String fromUser;
	private String date;		
	
	public String getFromCommunity() {
		return fromCommunity;
	}

	public void setFromCommunity(String fromCommunity) {
		this.fromCommunity = fromCommunity;
	}
	
	public String getFromUser() {
		return fromUser;
	}

	public void setFromUser(String fromUser) {
		this.fromUser = fromUser;
	}
	
	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}
	
	public Identity toIdentity() throws ParseException {
		Identity identity = new Identity();
		
		if(date != null) {
			SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
			identity.setDate(formatter.parse(date));
		}
		identity.setFromCommunity(fromCommunity);
		identity.setFromUser(fromUser);
		
		return identity;
		
	}
	
	
	
}